Namespacing everything to /UVa.
[andmenj-acm.git] / UVa / 11511 - Frieze Patterns / frieze.cpp
blob52a89be4c1718ea734aa93206ff91b762f6a6460
1 #include<iostream>
2 #include<cstdio>
3 #include<vector>
4 using namespace std;
6 int f[1005][1005];
8 int main(){
9 int n, row, col;
10 while (cin >> n >> row >> col && n){
11 for (int i=0; i<n; ++i) cin >> f[i][0];
12 for (int j=0; j<(n+1); ++j) f[0][j] = f[n-1][j] = 1;
13 for (int j=1; j<(n+1); ++j)
14 for (int i=1; i<n-1; ++i)
15 f[i][j] = (f[i+1][j-1]*f[i-1][j]+1)/f[i][j-1];
17 --row, --col;
18 cout << f[row][col%(n+1)] << endl;
20 return 0;